package com.hjc.springbootstudyweb.mapper;

import com.hjc.springbootstudyweb.entity.ProductModel;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: HJC
 * Date: 2019/12/1
 * Time: 21:56
 * To change this template use File | Settings | File Templates.
 */
public interface ProductsMapping {

    @Select("select * from product")
    @Results({
            @Result(property = "pid",column = "pid"),
            @Result(property = "pname" , column = "pname")
    })
    List<ProductModel> queryProduct();

    @Insert("insert into product(pname,type,price,repertory,describes) values(#{pname},#{type},#{price},#{repertory},#{describes})")
    @Options( useGeneratedKeys = true , keyProperty = "did" , keyColumn = "did")
    int addProduct(ProductModel productModel);

    @Delete("delete from product where pid=#{pid}")
    int deleteProduct(@Param("pid") int pid);
}
